package com.gxa.web_admin.controller;

import com.gxa.common.vo.JsonResult;
import com.gxa.common.vo.R;
import com.gxa.modules.pojo.Order;
import com.gxa.modules.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auth WK
 * @DATE 2022/9/13 15:28
 * @DESCRIBE
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 1.订单列表查询
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping("/findOrderList")
    public JsonResult findOrderList(Integer currentPage, Integer pageSize){
        return orderService.findOrderList(currentPage,pageSize);
    }

    /**
     * 2.订单审核
     * @param orderId
     * @return
     */
    @PostMapping("/checkOrder")
    public R checkOrder(Integer orderId){
        return orderService.checkOrder(orderId);
    }

    /**
     * 3.订单修改
     * @param order
     * @return
     */
    @PostMapping("/updateOrder")
    public R updateOrder(Order order){
        return orderService.updateOrder(order);
    }

    /**
     * 4.订单作废
     * @param orderId
     * @return
     */
    @PostMapping("/delectOrder")
    public R delectOrder(Integer orderId){
        return orderService.delectOrder(orderId);
    }

    /**
     * 5.查看订单详情
     * @param orderId
     * @return
     */
    @GetMapping("/findOrder")
    public JsonResult findOrder(Integer orderId){
        return orderService.findOrder(orderId);
    }


    /**
     * 6.条件查询订单
     * @param customerName
     * @param status
     * @param payTime
     * @return
     */
    @GetMapping("/findOrderByCondition")
    public JsonResult findOrderByCondition(String customerName, Integer status, String payTime, Integer currentPage, Integer pageSize){

        return orderService.findOrderByCondition(customerName,status,payTime,currentPage,pageSize);
    }
}
